package com.drakulo.hi.logic.actions;

import com.dk.hi.core.actor.Attribute;
import com.dk.hi.core.exceptions.HIException;
import com.drakulo.hi.logic.actors.Hero;

/**
 * <b>Heroes's attribute action</b>
 * <p>
 * Modify an attribute of th especified Hero
 * </p>
 */
public class AttributeModAction implements Action {
	/**
	 * The attribute to modify
	 */
	private Attribute attribute;

	/**
	 * Indicate if the attribute is to be initialized to the delta value. If it
	 * is set to false, the delta will be added or substraced depending on its
	 * sign
	 */
	private boolean isAbsoluteDelta;

	/**
	 * The delta value
	 */
	private Integer delta;

	/**
	 * The modifier target
	 */
	private Hero target;

	/**
	 * Constructor
	 * 
	 * @param hero
	 *            - The targer
	 * @param attribute
	 *            - The attribute to modify
	 * @param delta
	 *            - The value
	 * @param isAbsoluteDelta
	 *            - The absolute indicator
	 */
	public AttributeModAction(Hero hero, Attribute attribute, Integer delta, boolean isAbsoluteDelta) {
		this.target = hero;
		this.attribute = attribute;
		this.delta = delta;
		this.isAbsoluteDelta = isAbsoluteDelta;
	}

	@Override
	public void run() throws HIException {
		// if (this.isAbsoluteDelta) {
		// this.target.setAttribute(this.attribute, this.delta);
		// } else {
		// this.target.setAttribute(this.attribute,
		// this.target.getAttribute(this.attribute) + this.delta);
		// }
	}

}
